<template>
	<view class="content">
		<view class="C000 fs24 lh80 flexBox">
			<view :class="num==index? 'Cfe0000':''" v-for="(item,index) in NavTab" @click="Nav(index)" :key="index">{{item}}</view>
			
		</view>
		<view v-if="num==0">
			
			<view class="lis">
				<view v-for="(item,index) in orderData" :key="index" class="li">
					<view class="liTop">
						<view class="fl fs20 C6">
							{{item.lg_add_time |formatDate}}
							<!-- 会员编号：{{item.lg_member_id}} -->
							<!-- {{item.lg_desc}} -->
						</view>
						<view class="fr fs22 bold">
							{{item.lg_av_amount}}
						</view>
					</view>				
					<view style="clear: both;" class="liBottom">
						<view class="fl fs20 C6">
							{{item.lg_desc}}
							<!-- {{item.lg_type=='order_pay'?'订单支付':''}} -->
							<!-- 余额支付 -->
						</view>
						<!-- <view class="fr fs20 C999">
							{{item.lg_add_time |formatDate}}
						</view> -->
					</view>
				</view>
			</view>
			<view v-if="orderData.length<=0" class="None">
				<image style="width: 100%;" :src="`${picUrl}/InfoNull.png`" mode="widthFix"></image>
			</view>
		</view>
		
		<view v-if="num=='qqq'">
			<view class="lis">
				<view v-for="(item,index) in lpkList" :key="index" class="li">
					<view class="liTop">
						<view class="fl fs20 C6">
							{{item.createTime}}
						</view>
						<view class="fr fs22 bold">
							{{item.amount}}
						</view>
					</view>				
					<view style="clear: both;" class="liBottom">
						<view class="fl fs20 C6">
							{{item.pl_desc}}
							<!-- 余额支付 -->
						</view>
					<!-- 	<view class="fr fs20 C999">
							{{item.createTime}}
						</view> -->
					</view>
				</view>
			</view>
			<view v-if="lpkList.length<=0" class="None">
				<image style="width: 100%;" :src="`${picUrl}/InfoNull.png`" mode="widthFix"></image>
			</view>
		</view>
		
		<view v-if="num==1">
			<view class="lis">
				<view v-for="(item,index) in lpkList" :key="index" class="li">
					<view class="liTop">
						<view class="fl fs20 C6">
							{{item.pl_addtime |formaDate}}
						</view>
						<view class="fr fs22 bold">
							{{item.pl_points}}
						</view>
					</view>				
					<view style="clear: both;" class="liBottom">
						<view class="fl fs20 C6">
							{{item.pl_desc}}
						</view>
					
					</view>
				</view>
			</view>
			<view v-if="lpkList.length<=0" class="None">
				<image style="width: 100%;" :src="`${picUrl}/InfoNull.png`" mode="widthFix"></image>
			</view>
		</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				NavTab:["预存款明细","积分明细"],
				lg_add_time:{},
				orderData:[],
				order_id:[],
				order_id_id:[],
				member_info:"",
				num:0,
				lpkList:[],
				curpage:1,
				isInit:false,
				hasmore:false,//判断翻页
			}
		},
		 //时间戳的处理    
		filters: {
			formatDate: function(value) {
				var date = new Date();
				//date.setTime(value);
				var month = date.getMonth() + 1;
				var hours = date.getHours();
				if (hours < 10)
					hours = "0" + hours;
				var minutes = date.getMinutes();
				if (minutes < 10)
					minutes = "0" + minutes;
				var time = date.getFullYear() + "-" + month + "-" + date.getDate() +
					" " + hours + ":" + minutes;
				return time;
			}

		},
		watch:{
			num(val){
				if(this.num === val && !this.isInit){
					this.isInit = true
					if(index==0){
						this.getZixunData();
					}else if(index=="qqq"){
						this.getList();
					}else if(index==1){
						this.getintegral();
					}
				}
			}
		},
		onLoad(e) {
			this.num=e.index||0;
			if(this.num==0){
				this.getZixunData();
			}else if(this.num=="qqq"){
				this.getList();
			}else if(this.num==1){
				this.getintegral();
			}
		},
		onReachBottom() {
			if(this.num==0){
				if(this.hasmore){
					this.getZixunData(true)
				}else{
					uni.showToast({
						title:'已是最后一页！',
						icon:'none'
					})
				}
			}else if(this.num=="qqq"){
				if(this.hasmore){
					this.getList(true)
				}else{
					uni.showToast({
						title:'已是最后一页！',
						icon:'none'
					})
				}
			}else if(this.num==1){
				if(this.hasmore){
					this.getintegral(true)
				}else{
					uni.showToast({
						title:'已是最后一页！',
						icon:'none'
					})
				}
			}
			
		},
		methods: {
			Nav(index){
				this.num=index;
				this.curpage = 1
				this.hasmore=false
				if(this.num==0){
					this.getZixunData();
				}else if(this.num=="qqq"){
					this.getList();
				}else if(this.num==1){
					this.getintegral();
				}
			},
			getZixunData(state=false){//余额明细
				let that = this;
				this.$util.request({
			 		url: '/mobile/index.php?act=predeposit&op=yck_list',
					method: 'get',
					data: {curpage:this.curpage},
				}).then(function(res) {
					if(res.error_code==0){
						that.hasmore=res.datas.paged.hasmore
						if(state){//列表数据
							that.orderData = that.orderData.concat(res.datas.list) 
						}else{
							that.orderData = res.datas.list
						}
						that.curpage++;
					}else{
						uni.showToast({
							icon:"none",
							title:res.message
						})
					}
				})
			},
			getList(state=false){//礼品卡明细
				let that = this;
				this.$util.request({
					url: '/mobile/index.php?act=shopping_gold&op=getEhPointLogs',
					method: 'get',
					data: {
						curpage:this.curpage,
						type:1
					},
				}).then(function(res) {
					if(res.error_code==0){
						that.hasmore=res.datas.page.hasmore
						if(state){//列表数据
							that.lpkList = that.lpkList.concat(res.datas.list) 
						}else{
							that.lpkList = res.datas.list
						}
						that.curpage++;
						
					}else{
						uni.showToast({
							icon:"none",
							title:res.message
						})
					}
				})
			},
			getintegral(state=false){//积分明细
				let that = this;
				this.$util.request({
					url: '/mobile/index.php?act=member_points&op=index',
					method: 'get',
					data: {
						curpage:this.curpage,
					},
				}).then(function(res) {
					if(res.error_code==0){
						that.hasmore=res.datas.page.hasmore
						if(state){//列表数据
							that.lpkList = that.lpkList.concat(res.datas.list_log) 
						}else{
							that.lpkList = res.datas.list_log
						}
						that.curpage++;
						// if(that.curpage>=res.datas.page_total){
						// 	that.curpage=false;
						// }
					}else{
						uni.showToast({
							icon:"none",
							title:res.message
						})
					}
				})
			}

		}
	}
</script>

<style>
	.flexBox{
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.flexBox>view{
		width: 50%;
		text-align: center;
		margin: 20rpx 0;
	}
	.None{
		font-size: 30rpx;
		font-weight: bold;
		text-align: center;
		/* margin: 40rpx 0; */
		}
	.lh20{
		line-height: 20upx;
		height: 20upx;
	}
	.lh25{
		line-height: 25upx;
	}
	.lh30{
		line-height: 30upx;
	}
	.lh35{
		line-height: 35upx;
	}
	.lh40{
		line-height: 40upx;
	}
	.lh45{
		line-height: 45upx;
	}
	.lh50{
		line-height: 50upx;
	}
	.lh80{
		line-height: 80upx;
	}
	.C000{
		color: #000000;
	}
	.Ce13d97{
		color: #ff4300;
	}
	.Cfe0000{
		color: #ff4300;
	}
	.Cc06{
		color: #ff4300;
	}
	.mt55mb30{
		margin-top: 55upx;
		margin-bottom: 30upx;
	}
	.Cfff{
		color: #FFFFFF;
	}
	
	.flex{		
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-content: space-between;
	}
	.paddingL20{
		padding-left: 20upx;
	}
	.C999{
		color:#999 ;
	}
	.Cff0101{
		color:#ff0101 ;
	}
	.Cc00251{
		color: #c00251;
	}
	.strick{
		text-decoration: line-through;
	}
	.Cfe0000{
		color: #ff4300;
	}
	.line1{
		width: 430upx;
	}
	.hide{
		display: none;
	}
	.marginB20{
		margin-bottom: 20upx;
	}
	
	.twoline{
	   overflow : hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}
	.pl20{
		padding-left: 20upx;
	}
	.positionT{
		position: relative;
		top: 50upx;
	}
	.paddingB15{
		padding-bottom: 15upx;
	}
	.borderB{
		border-bottom: 1px solid #f4f4f6;
	}
	.borderT{
		border-top: 1px solid #f4f4f6;
	}
	.gl{
		position: absolute;
		right: 30upx;
	}
	.pr30{
		padding-right: 30upx;
	}
	.C333{
		color: #333333;
	}
	.C666{
		color: #666666;
	}
	.Cf00{
		color: #ff0000;
	}
	
	.bold{
		font-weight: bold;
	}
	.C1d1d1d{
		color:#1d1d1d ;
	}
	.fl{
		float: left;
	}
	.fr{
		float: right;
	}
	.tac{
		text-align: center;
	}
	.Ce5258e{
		color: #e5258e;
	}
	.Cccc{
		color: #CCCCCC;
	}
	uni-page-body {
		background-color: #FFFFFF;
		color: rgb(102, 102, 102);
	}		
	.fs30{
		/* font-size: 30upx */
		font-size: 45upx
	}
	.fs26{
		font-size:39upx
		/* font-size: 26upx */
	}
	.fs12{
		font-size: 18upx
		/* font-size: 12upx */
	}
	.fs16{
		font-size: 24upx
		/* font-size: 16upx */
	}
	.fs14{
		font-size: 21upx
		/* font-size: 14upx */
	}
	.fs15{
		font-size: 22.5upx
		/* font-size: 15upx */
	}
	.fs27{
		font-size: 40.5upx
		/* font-size: 27upx */
	}
	.fs18{
		font-size: 27upx
		/* font-size: 18upx */
	}
	.fs28{
		font-size: 42upx
		/* font-size: 28upx */
	}
	.fs10{
		font-size: 15upx
		/* font-size: 10upx */
	}
	.fs30{
		font-size: 45upx
		/* font-size: 28upx */
	}
	.fs24{
		font-size: 36upx
		/* font-size: 24upx */
	}
	.fs20{
		font-size:30upx
		/* font-size: 20upx */
	}
	.fs22{
		font-size:33upx
		/* font-size: 22upx */
	}
	.fs21{
		font-size: 31.5upx
		/* font-size: 21upx */
	}
	view{
		box-sizing: border-box;
	}
	.content{
		min-height: 100vh;
		box-sizing: border-box;
		background-color: #FFFFFF;
		padding: 0 26upx;
	}
	.zichan{
		display: flex;
		flex-direction: row;
		justify-content: space-around;
		align-content: space-around;
	}
	.lis{
		/* margin-top:50upx ; */
	}
	.li{
		padding-top: 10upx;
		padding-bottom: 10upx;
		border-bottom: 1upx solid #f4f4f4;
		overflow: hidden;
	}


</style>
